import collections


components={}
components2={}
components3={}
components['arc-ce']=('bio.ndgf.org'',''ATLAS','IceCube','SweGrid','Biogrid','nordugrid.org','balticgrid','SMSCG')
components['CREAM-WN']=('lsgrid','vlemed','esr','bbmri.nl','lofar','Auger','VOCE','VO-MPI','vo.plgrid.pl','see','seegrid','seismo.see-grid-sci.eu','env.see-grid-sci.eu','meteo.see-grid-sci.eu','eumed','biomed','nabics','nuclearby','see','seegrid','meteo.see-grid-sci.eu','seismo.see-grid-sci.eu','env.see-grid-sci.eu','vo.aginfra.eu','atlas','alice','lhcb','cms','dech','compass','babar','dzero','ops','cdf','auger','belle','astrogrid','enmr','biomed','meteo.see-grid-sci.eu','seismo.see-grid-sci.eu','env.see-grid-sci.eu','LHC-VOsphys.vo.ibergrid.eu','ict.vo.ibergrid.eu','eng.vo.ibergrid.eu','social.vo.ibergrid.eu','earth.vo.ibergrid.eu','chem.vo.ibergrid.eu','life.vo.ibergrid','auger','biomed','enmr.eu','magic','fusion','vo.cta.in2p3.fr','compchem','imath.cesga.es','vo.paus.pic.es','t2k.org','alice','atlas','biomed','esr','hone','voce','mpi-kickstar')
components['gLexec']=('LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs',)
components['gLite-mpi']=('cesga','phys.vo.ibergrid.euhpc.vo.ibergrid.euiber.vo.ibergrid.eu','lsgrid','vlemed','esr','bbmri.nl','lofar','Auger','VOCE','VO-MPI','see','seegrid','seismo.see-grid-sci.eu','env.see-grid-sci.eu','meteo.see-grid-sci.eu','eumed','biomed','nabics','nuclearby','atlas','alice','lhcb','cms','dech','compass','babar','dzero','ops','cdf','auger','belle','astrogrid','enmr','phys.vo.ibergrid.eu','ict.vo.ibergrid.eu','eng.vo.ibergrid.eu','social.vo.ibergrid.eu','earth.vo.ibergrid.eu','chem.vo.ibergrid.eu','life.vo.ibergrid','auger','biomed','enmr.eu','magic','fusion','vo.cta.in2p3.fr','compchem','imath.cesga.es','vo.paus.pic.es','t2k.org','meteo.see-grid-sci.eu','seismo.see-grid-sci.eu','env.see-grid-sci.eu','mpi-kickstar')
components['WMSLB']=('lsgrid','vlemed','esr','bbmri.nl','lofar','Auger','VOCE','VO-MPI','see','seegrid','seismo.see-grid-sci.eu','env.see-grid-sci.eu','meteo.see-grid-sci.eu','eumed','biomed','nabics','nuclearby','see','seegrid','meteo.see-grid-sci.eu','seismo.see-grid-sci.eu','env.see-grid-sci.eu','vo.aginfra.eu','atlas','alice','lhcb','cms','dech','compass','babar','dzero','ops','cdf','auger','belle','astrogrid','enmr','LHC_VOs','phys.vo.ibergrid.eu','ict.vo.ibergrid.eu','eng.vo.ibergrid.eu','social.vo.ibergrid.eu','earth.vo.ibergrid.eu','chem.vo.ibergrid.eu','life.vo.ibergrid','auger','biomed','enmr.eu','magic','fusion','vo.cta.in2p3.fr','compchem','imath.cesga.es','vo.paus.pic.es','t2k.org','alice','atlas','biomed','esr','hone','voce','mpi-kickstar')
components['Torque']=('lsgrid','vlemed','esr','bbmri.nl','lofar','see','seegrid','seismo.see-grid-sci.eu','env.see-grid-sci.eu','meteo.see-grid-sci.eu','eumed','biomed','nabics','nuclearby','see','seegrid','meteo.see-grid-sci.eu','seismo.see-grid-sci.eu','env.see-grid-sci.eu','vo.aginfra.eu','atlas','alice','lhcb','cms','dech','compass','babar','dzero','ops','cdf','auger','belle','astrogrid','enmr','phys.vo.ibergrid.eu','ict.vo.ibergrid.eu','eng.vo.ibergrid.eu','social.vo.ibergrid.eu','earth.vo.ibergrid.eu','chem.vo.ibergrid.eu','life.vo.ibergrid','auger','biomed','enmr.eu','magic','fusion','vo.cta.in2p3.fr','compchem','imath.cesga.es','vo.paus.pic.es','t2k.org','alice','atlas','biomed','esr','hone','voce','mpi-kickstar')
components['GE']=('phys.vo.ibergrid.eu','ict.vo.ibergrid.eu','eng.vo.ibergrid.eu','social.vo.ibergrid.eu','earth.vo.ibergrid.eu','chem.vo.ibergrid.eu','life.vo.ibergrid','auger','biomed','enmr.eu','magic','fusion','vo.cta.in2p3.fr','compchem','imath.cesga.es','vo.paus.pic.es','t2k.org')
components['LSF']=('LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','phys.vo.ibergrid.eu','ict.vo.ibergrid.eu','eng.vo.ibergrid.eu','social.vo.ibergrid.eu','earth.vo.ibergrid.eu','chem.vo.ibergrid.eu','life.vo.ibergrid','auger','biomed','enmr.eu','magic','fusion','vo.cta.in2p3.fr','compchem','imath.cesga.es','vo.paus.pic.es','t2k.org')
components['UNICORE-TSI-WS-X']=('shiwa-workflow.eu','astrogrid','bwgrid','medigrid','dgtest','vo.plgrid.pl')
components['GRAM']=('astrogrid','bwgrid','medigrid','dgtest')

components2['ARC gridftp']=('ATLAS','SMSCG','nordugrid.org','balticgrid','biomed','seegrid','margi','meteo.see-grid-sci.eu','seismo.see-grid-sci.eu','env.see-grid-sci.eu','SweGrid','IceCube','Biogrid',)
components2['dCache']=('LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs',' biomed')
components2['DPM']=('LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','Cesga','phys.vo.ibergrid.eu','hpc.vo.ibergrid.eu','iber.vo.ibergrid.eu','SMSCG','aegis','see','seegrid','sgdemo','meteo.see-grid-sci.eu','seismo.see-grid-sci.eu', 'env.see-grid-sci.eu',' biomed')
components2['Globus GridFTP']=()
components2['StoRM']=('LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs','LHC-VOs',)
components2['UNICORE']=()

components3['BDII']=('Almost all the VOs',)
components3['ARC infosys']= ('ATLAS','ALICE','CMS','SMSCG','bio.ndgf.org','nordugrid.org','balticgrid', 'SweGrid', 'IceCube','Biogrid')
components3['UNICORE']=('',)



for key in components.keys():
	l = components[key]
	l_items = set(l) # produce the items without duplicates
	l_counts = [ (l.count(x), x) for x in set(l)]
	l_counts.sort(reverse=True)
	# sort the list of items, reversing is so that big items are first
	l_result = [ y for x,y in l_counts ]
	# get rid of the counts leaving just the items
	print key,
	print l_result
	
	
	

for key in components2.keys():
	l = components2[key]
	l_items = set(l) # produce the items without duplicates
	l_counts = [ (l.count(x), x) for x in set(l)]
	l_counts.sort(reverse=True)
	# sort the list of items, reversing is so that big items are first
	l_result = [ y for x,y in l_counts ]
	# get rid of the counts leaving just the items
	print key,
	print l_result
	
	

for key in components3.keys():
	l = components3[key]
	l_items = set(l) # produce the items without duplicates
	l_counts = [ (l.count(x), x) for x in set(l)]
	l_counts.sort(reverse=True)
	# sort the list of items, reversing is so that big items are first
	l_result = [ y for x,y in l_counts ]
	# get rid of the counts leaving just the items
	print key,
	print l_result
